#!/bin/bash

source "$METIS_HOME"metis.config
#not really pausing it - but hey-ho - THIS HAS NOW BEEN REPLACED BY stop-job.sh
#This is a very simple, temporary, script. It is used to control basic scheduling of scans, i.e when a job needs pausing, i.e. if you are only allowed to scan during business hours, it will recursively kill the man script and all scans as a result. It will then re-populate the targets.txt for scans that haven't started yet. Nothing is done regarding killed scans. Killed scans will be detected when the nmap parsing script is run. These will then need to be re-run.

#It is really simple, and therefore you can only use it reliably when running one scan type. This is because it bases whether a scan has been attempted on an IP based on the creation of directory with that IPs name. It is recommended if using this, that you run each scan type of a different server

pid=`cat ${procID}`

# kill all the processes
"$utilsDir"killtree.sh "$pid" 9

ls "$nmapOutputDir" > "$workingDir"targets.attempted

diff "$workingDir"targets.attempted "$workingDir"targets.original > "$workingDir"diff.txt

cat "$workingDir"diff.txt | grep ">" | sed 's/> //' > "$workingDir"targets.txt

rm "$workingDir"diff.txt
